<html>
<head>
<title>ZipIt.exe and UnZip.exe</title>
<style>
p,body,a,tr,td
             { font-family: Verdana, Arial, Helvetica; font-size: 10pt }
h1,h2,h3,h4,h5,h6
             { font-family: Verdana, Arial, Helvetica; font-weight: normal; font-style: normal; }
h1           { font-size: 20pt }
h2           { font-size: 18pt; font-weight:bold; color: navy }
h3           { font-size: 16pt; font-weight:bold; color: #483d8b }
h4           { font-size: 14pt; font-weight:bold; color:#C71585; margin-bottom:2px; }
.code       {font-family: Consolas, Courier; font-size: 10pt }
</style>


</head>
<!-- @SortOrder 1 -->
<body>
<h1>DotNetZip Command-Line Tools</h1>

<p>The Tools/Utilities downloads for DotNetZip include a pair of tools -
Zipit.exe and Unzip.exe - that can be used from the command line to
manipulate zip files from within batch scripts, or CMD.exe windows.
</p>


<h2>ZipIt.exe</h2>

<p>This tool can be used to create ZIP files, or update existing ZIP
files, from the command line or from a batch file. </p>

<p>Using the command line tools, you can do virtually everything you can
do by using the library directly from a custom application.  You can
create self-extracting archives or archives that use ZIP64 extensions.
You can create archives that use encryption or passwords.  You can
create split or spanned archives. And there are many other options. </p>


<!-- ============================================================== -->

<h3>Usage</h3>
<pre  numberLines="true" outlining="true" >

ZipIt.exe &lt;ZipFileToCreate&gt; [arguments]

arguments:
  &lt;directory&gt; | &lt;file&gt; - a directory or file to add to the archive.
  &lt;selector&gt;           - a file selection expression.  Examples:
                           *.txt
                           (name = *.txt) OR (name = *.xml)
                           (attrs = H) OR (name != *.xml)
                           (ctime &lt; 2009/02/28-10:20:00)
                           (size &gt; 1g) AND (mtime &lt; 2009-06-29)
                           (ctime &gt; 2009-04-29) AND (size &lt; 10kb)
                         Filenames can include full paths. You must surround a filename
                         that includes spaces with single quotes.
  -64                  - use ZIP64 extensions, for large files or large numbers of files.
  -aes                 - use WinZip-compatible AES 256-bit encryption for entries
                         subsequently added to the archive. Requires a password.
  -cp &lt;codepage&gt;       - use the specified numeric codepage for entries with comments
                         or filenames that cannot be encoded with the default IBM437
                         code page.
  -d &lt;path&gt;            - use the given directory path in the archive for
                         succeeding items added to the archive.
  -D &lt;path&gt;            - find files in the given directory on disk.
  -e&lt;s,r,q,a&gt;          - when there is an error reading a file to be zipped, either skip
                         the file, retry, quit, or ask the user what to do.
  -j-                  - do not traverse NTFS junctions
  -j+                  - traverse NTFS junctions (default)
  -L &lt;level&gt;           - compression level, 0..9 (Default is 6).
  -p &lt;password&gt;        - apply the specified password for all succeeding files added.
                         use "" to reset the password to nil.
  -progress            - emit progress reports (good when creating large zips)
  -r-                  - don't recurse directories (default).
  -r+                  - recurse directories.
  -s &lt;entry&gt; 'string'  - insert an entry of the given name into the
                         archive, with the given string as its content.
  -sfx [w|c]           - create a self-extracting archive, either a Windows or console app.
  -split &lt;maxsize&gt;     - produce a split zip, with the specified maximum size.  You can
                         optionally use kb or mb as a suffix to the size.
                         -split is not compatible with -sfx.
                         This is not compatible with -sfx.
  -Tw+                 - store Windows-format extended times (default).
  -Tw-                 - don't store Windows-format extended times.
  -Tu+                 - store Unix-format extended times (default).
  -Tu-                 - don't store Unix-format extended times (default).
  -UTnow               - use uniform date/time, NOW, for all entries.
  -UTnewest            - use uniform date/time, newest entry, for all entries.
  -UToldest            - use uniform date/time, oldest entry, for all entries.
  -UT &lt;datetime&gt;       - use uniform date/time, specified, for all entries.
  -utf8                - use UTF-8 encoding for entries with comments or
                         filenames that cannot be encoded with the default IBM437
                         code page.
  -zc &lt;comment&gt;        - use the given comment for the archive.

</pre>


<!-- ============================================================== -->

<h3>Command Examples</h3>

<table border='1'>
<tr>
  <td style='color:white;Background:Navy;'><strong>Use this Command...</strong></td>
  <td style='color:white;Background:Navy;'><strong>to do this...</strong></td>
</tr>

<tr>
  <td colspan='2' class="code">zipit.exe  NewZip.zip  -64  *.doc</td>
</tr>

<tr>
  <td>&nbsp;</td>
  <td>
  create a new zip file called NewZip.zip, adding all .doc files from
  the current directory
  into the zip.  Use ZIP64 extensions.
  </td>
</tr>

<tr>
  <td colspan='2' class="code">zipit.exe  NewZip.zip  -r+  *.doc</td>
</tr>

<tr>
  <td>&nbsp;</td>
  <td>
  create a new zip file called NewZip.zip, adding all .doc files, in the
  current directory and any child directories,
  into the zip.
  </td>
</tr>

<tr>
  <td colspan='2' class="code">zipit.exe  Backup.zip -d c:\MyDocuments  -r+ -j-  *.*</td>
</tr>

<tr>
  <td>&nbsp;</td>
  <td>
  create a new zip file called Backup.zip, adding all files within the c:\MyDocuments
  directory.  Do not traverse NTFS Junction points (like My Videos).
  </td>
</tr>

<tr>
  <td colspan='2' class="code">zipit.exe  Package.exe -sfx -d c:\files  -r+  *.*</td>
</tr>

<tr>
  <td>&nbsp;</td>
  <td>
  create a new self-extracting archive file called Package.exe, adding
  all files within the c:\files directory hierarchy.
  </td>
</tr>

<tr>
  <td colspan='2' class="code">zipit.exe  Package.zip -split 1mb  -d c:\files  -r+  *.*</td>
</tr>

<tr>
  <td>&nbsp;</td>
  <td>
  create a new "spanned" or multi-segment zip file called Package.zip, adding
  all files within the c:\files directory hierarchy.  Each segment of the zipfile should be
  limited to 1mb in size, and the segments will be named Package.z01, Package.z02, etc.
  </td>
</tr>


<tr>
  <td colspan='2' class="code">zipit.exe  ImageLibrary.zip -split 1mb  -d c:\images  -r+  "name = *.jpg AND size > 100kb"</td>
</tr>

<tr>
  <td>&nbsp;</td>
  <td>
  create a new "spanned" or multi-segment zip file called ImageLibrary.zip, adding
  all .jpg files within the c:\images directory hierarchy that have a size larger than 100kb.  Each segment of the zipfile should be
  limited to 1mb in size, and the segments will be named Package.z01, Package.z02, etc.
  </td>
</tr>

<tr>
  <td colspan='2' class="code">zipit.exe Portfolio.zip -p Secret! -aes -d c:\portfolio  -r+  "name != *.tfs"</td>
</tr>

<tr>
  <td>&nbsp;</td>
  <td>
  create a new aip file called Portfolio.zip, adding
  all files within the c:\portfolio directory hierarchy that do not have the .tfs extension.
  Encrypt all entries using AES 256-bit encryption.
  </td>
</tr>

<tr>
  <td colspan='2'  class="code">zipit.exe Portfolio.zip -p Secret! -aes -L 9 -d c:\portfolio  -r+  "name != *.tfs"</td>
</tr>

<tr>
  <td>&nbsp;</td>
  <td>
  create a new aip file called Portfolio.zip, adding
  all files within the c:\portfolio directory hierarchy that do not have the .tfs extension.
  Encrypt all entries using AES 256-bit encryption, and use level 9 (Best) compression.
  </td>
</tr>

</table>


<!-- ============================================================== -->

<h3>Syntax for the Selection Criteria</h3>

<p> Using the a selector string, you can specify a set of criteria for
the files to be added to the zip file.  Specify the criteria in
statements of 3 elements: a noun, an operator, and a value.  Consider
the string "name != *.doc" .  The noun is "name".  The operator is "!=",
implying "Not Equal".  The value is "*.doc".  That criterion, in
English, says "all files with a name that does not end in the .doc
extension."  </p>

<p> Supported nouns include <b>name</b> for the filename; <b>atime</b>,
<b>mtime</b>, and <b>ctime</b> for last access time, last modfied time,
and created time of the file, respectively; <b>attributes</b> for the
file attributes; and <b>size</b> for the file length (uncompressed).
The <b>attributes</b> and <b>name</b> nouns both support = and != as
operators.  The <b>size</b>, <b>atime</b>, <b>mtime</b>, and
<b>ctime</b> nouns support = and !=, and &gt;, &gt;=, &lt;, &lt;= as
well. The times are taken to be expressed in <em>local time</em>.  </p>

<p> Specify values for the file attributes as a string with one or more
of the characters H,R,S,A in any order, implying Hidden, ReadOnly,
System, and Archive, respectively.  To specify a time, use
YYYY-MM-DD-HH:mm:ss or YYYY/MM/DD-HH:mm:ss as the format.  If you omit the HH:mm:ss portion, it
is assumed to be 00:00:00 (midnight). The value for a size criterion is
expressed in integer quantities of bytes, kilobytes (use k or kb after
the number), megabytes (m or mb), or gigabytes (g or gb).  The value for
a name is a pattern to match against the filename, potentially including
wildcards.  The pattern follows CMD.exe glob rules: * implies one or
more of any character (not including dot), while ? implies one character
(not including dot).  If the name pattern contains any slashes, it is
matched to the entire filename, including the path; otherwise, it is
matched against only the filename without the path.  This means a
pattern of "*\*.*" matches all files one directory level deep, while a
pattern of "*.*" matches all files in all directories.  </p>


<p> To specify a name pattern that includes spaces, use single quotes
around the pattern.  A pattern of "'* *.*'" will match all files that
have spaces in the filename.  The full criteria string for that would be
"name = '* *.*'" .  </p>



<!-- ============================================================== -->

<h3>Examples of Selection Criteria</h3>

<table border='1'>
<tr>
  <td style='color:white;Background:Navy;'><strong>Use this Command...</strong></td>
  <td style='color:white;Background:Navy;'><strong>to do this...</strong></td>
</tr>

<tr>
  <td colspan='2' class="code">name = *.jpg</td>
</tr>

<tr>
  <td>&nbsp;</td>
  <td>any .jpg file
  </td>
</tr>

<tr>
  <td colspan='2' class="code">mtime &gt; 2009-07-14</td>
</tr>

<tr>
  <td>&nbsp;</td>

  <td>any file with a <em>last modified time</em> after midnight on 14 July
  2009. There is also ctime and atime for <em>created time</em> and <em>accessed
  time</em>.
  </td>
</tr>

<tr>
  <td  colspan='2' class="code">ctime &gt; 2009-07-14-07:53:00</td>
</tr>

<tr>
  <td>&nbsp;</td>

  <td>any file with a <em>created time</em> after 7:53am (local time) on 14 July 2009.
  </td>
</tr>

<tr>
  <td colspan='2' class="code">size &gt; 320mb</td>
</tr>

<tr>
  <td>&nbsp;</td>

  <td>
any file with a size over 320mb.  You can use <b>kb</b> or <b>gb</b>, too.  Or
omit the characters to specify a filesize in bytes. And you can use &lt;, &gt;, or = as
operations.
  </td>
</tr>

<tr>
  <td colspan='2' class="code">attr != H</td>
</tr>

<tr>
  <td>&nbsp;</td>

  <td>
any file that does not have the Hidden attribute set. Other attributes
include S=system, R=Readonly, A=Archive.  Of course you can test that
the attribute is ON as well, using = instead of !=.
  </td>
</tr>

<tr>
  <td colspan='2' class="code">attr != H and size &gt; 320mb</td>
</tr>

<tr>
  <td>&nbsp;</td>

  <td>
include the files that satisfy both conditions.  You can also use OR as a conjuction. Use parens to group complex expressions.

  </td>
</tr>

<tr>
  <td colspan='2' class="code">name = *.jpg or name = *.gif</td>
</tr>

<tr>
  <td>&nbsp;</td>

  <td>
include the files that satisfy one or the other condition.
  </td>
</tr>

<tr>
  <td colspan='2' class="code">(name = *.jpg) or (name = *.gif)</td>
</tr>

<tr>
  <td>&nbsp;</td>

  <td>
same as above.
  </td>
</tr>

<tr>
  <td colspan='2' class="code">(mtime &gt;= 2009-07-01) and (mtime &lt; 2009-07-02)</td>
</tr>

<tr>
  <td>&nbsp;</td>

  <td>
any file modified on July 1st.  From midnight to midnight.
  </td>
</tr>

<tr>
  <td colspan='2' class="code">(name = *.jpg) AND (mtime &gt;= 2009/07/01) and (mtime &lt; 2009/07/02)</td>
</tr>

<tr>
  <td>&nbsp;</td>

  <td>
any .jpg file modified on July 1st.
  </td>
</tr>

<tr>
  <td colspan='2' class="code">(name = *.jpg) and (size &gt;= 100kb) and (mtime &gt;= 2009/07/01) and (mtime &lt; 2009/07/02)</td>
</tr>

<tr>
  <td>&nbsp;</td>

  <td>
any .jpg file, 100kb or more in size, modified on July 1st.
  </td>
</tr>

</table>


<!-- ============================================================== -->

<h2>UnZip.exe</h2>

<p>This tool can be used to view, extract, or test and verify ZIP files,
from the command line or from a batch file. </p>


<!-- ============================================================== -->

<h3>Usage</h3>

<pre>
  UnZip.exe [options] &lt;zipfile&gt; [&lt;entryname&gt;...]
     unzips all files in the archive.
     options:
       -o                overwrite existing files if necessary.
       -f                flatten directory structure when extracting.
       -p &lt;password&gt;     specify password for extraction.
       -t                test the file for consistency.
       -q                operate quietly (no verbose messages).
       -cp &lt;codepage&gt;    extract with the specified numeric codepage.  Only do this if you
                         know the codepage, and it is neither IBM437 nor UTF-8. If the
                         codepage you specify here is different than the codepage of
                         the cmd.exe, then the verbose messages will look odd, but the
                         files will be extracted properly.
       -d &lt;directory&gt;    unpack to the specified directory. If none provided, it will
                         unzip to the current directory.
       &lt;entryname&gt;       unzip only the specified filename.

  unzip -l &lt;zipfile&gt;
     lists the entries in the zip archive.
  unzip -i &lt;zipfile&gt;
     displays full information about all the entries in the zip archive.
  unzip -t &lt;zipfile&gt; [-p &lt;password&gt;] [-cp &lt;codepage&gt;]
     tests the zip archive.
  unzip -?
     displays this message.

</pre>




<h3>Command Examples</h3>

<table border='1'>
<tr>
  <td style='color:white;Background:Navy;'><strong>Use this Command...</strong></td>
  <td style='color:white;Background:Navy;'><strong>to do this...</strong></td>
</tr>

<tr>
  <td colspan='2' class="code">UnZip.exe -l Package.zip </td>
</tr>

<tr>
  <td>&nbsp;</td>
  <td>
  list the entries in the zipfile, along with basic information about each entry.
  </td>
</tr>


<tr>
  <td colspan='2' class="code">UnZip.exe Package.zip </td>
</tr>

<tr>
  <td>&nbsp;</td>
  <td>
  extract the entries in the zipfile, into the current directory.
  </td>
</tr>

<tr>
  <td colspan='2' class="code">UnZip.exe Package.zip -d ex1 </td>
</tr>

<tr>
  <td>&nbsp;</td>
  <td>
  extract the entries in the zipfile, into the directory 'ex1'. The directory will
  be created if it does not exist.
  </td>
</tr>

<tr>
  <td colspan='2' class="code">UnZip.exe Package.zip -f -d ex1 </td>
</tr>

<tr>
  <td>&nbsp;</td>
  <td>
  extract the entries in the zipfile, into the directory 'ex1'. The directory will
  be created if it does not exist.  Any directory hierarchy within the zip file
  will be ignored or "flattened" upon extraction.
  </td>
</tr>


<tr>
  <td colspan='2' class="code">UnZip.exe Package.zip -o -d ex1 </td>
</tr>

<tr>
  <td>&nbsp;</td>
  <td>
  extract the entries in the zipfile, into the directory 'ex1'. The directory will
  be created if it does not exist.  During extraction, any existing files in the
  directory hierarchy will be overwritten if necessary.
  </td>
</tr>


</table>



</body>
</html>
